﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ProductTasteManager : ASPXBaseClass
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"].ToString() != "admin")
        {
            Response.Redirect("~/Admin/RedirectLogin.htm");
        }
        if (!IsPostBack)
        {
            BindRpt();
        }
    }

    void BindRpt()
    {
        this.rptTasteList.DataSource = new GZ.Entity.Etaste().GetTaste();
        this.rptTasteList.DataBind();
    }

    /// <summary>
    /// 行事件
    /// </summary>
    /// <param name="source"></param>
    /// <param name="e"></param>
    protected void rptTasteList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int Id = Convert.ToInt16(e.CommandArgument);
        if (e.CommandName == "Del")
        {
            if (new GZ.Entity.Etaste().Del(Id))
            {
                BindRpt();
            }
        }
    }

    /// <summary>
    /// 添加口味
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        GZ.Entity.Etaste obj = new GZ.Entity.Etaste();
        obj.TasteName = this.txtTasteName.Text;
        obj.StartKey = this.txtStartKey.Text;
        obj.EndKey = this.txtEndKey.Text;
        if (obj.Insert(obj))
        {
            BindRpt();
        }

    }
}